# Contributor: Rasmus Thomsen <oss@cogitri.dev>

# The group tag is just to easily find this APKBUILD by some scripts for automation
# group=kde-plasma
maintainer="team/kde <bribbers@disroot.org>"
pkgname=xdg-desktop-portal-kde
pkgver=6.2.3
pkgrel=0
pkgdesc="A backend implementation for xdg-desktop-portal that is using Qt/KDE"
# armhf blocked by extra-cmake-modules
arch="all !armhf"
url="https://phabricator.kde.org/source/xdg-desktop-portal-kde"
license="LGPL-2.0-or-later"
depends="xdg-desktop-portal"
makedepends="
	cups-dev
	extra-cmake-modules
	glib-dev
	kcoreaddons-dev
	kdeclarative-dev
	kio-dev
	kirigami-dev
	kstatusnotifieritem-dev
	kwayland-dev>=$pkgver
	libepoxy-dev
	pipewire-dev
	libplasma-dev
	plasma-wayland-protocols
	qt6-qtbase-dev
	samurai
	xdg-desktop-portal-dev
	"
checkdepends="
	dbus-x11
	py3-gobject3
	xvfb-run
	"
subpackages="$pkgname-lang"

case "$pkgver" in
	*.90*) _rel=unstable;;
	*) _rel=stable;;
esac
_repo_url="https://invent.kde.org/plasma/xdg-desktop-portal-kde.git"
source="https://download.kde.org/$_rel/plasma/$pkgver/xdg-desktop-portal-kde-$pkgver.tar.xz"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DKDE_INSTALL_LIBEXECDIR=libexec
	cmake --build build
}

check() {
	# colorschemetest requires the package itself installed
	xvfb-run -a ctest --test-dir build --output-on-failure -E "colorschemetest"
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	rm -rf "$pkgdir"/usr/lib/systemd
}

sha512sums="
252b81b018be3523a1dd38a326f4d899ad1f3e43bc1e937202c0e71ee8b6454ea975c6aa3b1684ba99428dbc45ee3e2ec5159dc0bdfac522af5b6cfd8b7f7f86  xdg-desktop-portal-kde-6.2.3.tar.xz
"
